import java.util.Arrays;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class Day41 {
    static final int N = 20;
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            // 构造棋盘
            char[][] map = new char[N][N];
            for (int i = 0; i < N; i++) {
                map[i] = in.nextLine().toCharArray();
            }
            boolean res = slove(map);
            System.out.println(res ? "Yes":"No");

            // 输出验证
//            for (int i = 0; i < N; i++) {
//                System.out.println(Arrays.toString(map[i]));
//            }
        }
    }

    private static boolean slove(char[][] map) {
        // 从上到下遍历判断胜负
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (map[i][j] == '+' || map[i][j] == '*') {
                    // **这里条件是大于等于 5 因为棋盘存在大于五个相同的情况**
                    if (count(map,i,j,map[i][j]) >= 5) {
                        return (true);
                    }
                }
            }
        }
        return (false);
    }

    private static int count(char[][] map, int x, int y, char c) {
        // 判断胜负（五子连珠：上下-左右-左上右下-左下右上）
        int[][][] directs = {
                {{1,0},{-1,0}},
                {{0,-1},{0,1}},
                {{-1,-1},{1,1}},
                {{1,-1},{-1,1}}};
        int count = 0;
        int maxCount = 0;
        for (int i = 0; i < 4; i++) {
            count = 0;
            // 四个大方向
            for (int j = 0; j < 2; j++) {
                int nx = x;
                int ny = y;
                // 循环向一个方向查找，直到遇到边界或者非当前字符
                while (nx < N && nx >= 0 && ny < N && ny >= 0 && map[nx][ny] == c) {
                    count ++;
                    nx = nx + directs[i][j][0];
                    ny = ny + directs[i][j][1];
                }
            }
            maxCount = count > maxCount? count:maxCount;
        }
        // x y 会被计算两次这里需要剔除一个
        return maxCount - 1;
    }

    /**
     * 逆波兰表达式求值
     * @param args
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            String[] src = new String[n];
            for (int i = 0; i < n; i ++) {
                src[i] = in.next();
            }
            Deque<Integer> stack = new LinkedList<>();
            for (int i = 0; i < src.length; i ++) {
                if (!src[i].equals("+") && !src[i].equals("-")
                        && !src[i].equals("*") && !src[i].equals("/")) {
                    // 入栈
                    stack.push(Integer.parseInt(src[i]));
                } else {
                    // 出栈
                    int b = stack.pop();
                    int a = stack.pop();

                    int res = calculate(a,b,src[i]);
                    // 结果入栈
                    stack.push(res);
                }
            }
            System.out.println(stack.pop());
        }
    }

    private static int calculate(int a, int b, String ch) {
        if (ch.equals("+")) {
            return a + b;
        } else if (ch.equals("-")) {
            return a - b;
        } else if (ch.equals("*")) {
            return a * b;
        } else {
            return a / b;
        }
    }
}
